#include <stdio.h>

#include <UserAPI.h>
#include <Kernel.h>
/*
int File1 (void)
{
    printf("\n I am FILE1 NEED TO BE READ\n");
    return openfile("Aname");
}

int File2 (void)
{
    printf("\n I am FILE2  READ ME NOW\n");
    return openfile("Bname");
}*/

int FileVirtual (void)
{
    printf("\n I am TASK OF VFS_TESTING  READ ME NOW\n");
    return openfile("Bname");
}




int func1(void)
{
    printf("\n I am func1 don't interrupt me\n");
    return 0;
}

int func2(void)
{
    printf("\n I am func2 don't interrupt me\n");
    return 0;
}

int func3(void)
{
    printf("\n I am func3 don't interrupt me\n");
    return 0;
}

/************************************Testings**************************************/
#ifdef _Debug_of_Schelduller
void Test_openfile(void);
int main()
{
    int a=1;
    if(a==0)
    {

    var_t*   data1;
    var_t*   data2;
    var_t*   data3;
    var_t*   data4;
    var_t*   data5;

        Kernel_boot();
        Kernel_initdata(&data1);
        Kernel_initdata(&data2);
        Kernel_initdata(&data3);
        Kernel_initdata(&data4);
        Kernel_initdata(&data5);

       /* Kernel_SchelduleEvery(File1,700,data4);*/
        Kernel_SchelduleEvery(func1,200,data1);/*millisecond scale, according to program delay of 10 second*/
        Kernel_SchelduleEvery(func2,300,data2);
       /* Kernel_SchelduleEvery(File2,300,data5);*/
        Kernel_SchelduleEvery(func3,400,data3);
        Kern_RunSchel();
        Kern_Shutdown();
    }
    if(a==1)
    {
        char       line[200];
        int        linesize;
        FILE*      fp;
        var_t*     data6;

        Kernel_boot();
        VFS_Create();
        VFS_mkdir("/home");
        VFS_openfile("/home/Gilad",S_CREATE);
        printf("\n\n WRITING  AND READING  FROM FILE\n\n");
        fp=fopen("vfsystemGilad.h","r");
        while(1)
        {
            fgets(line,199,fp);
            if(feof(fp))
            {
                break;
            }
            linesize=strlen(line);
            line[linesize]='\0';
            VFS_write(0,linesize,line);
            if(feof(fp))
            {
                break;
            }
        }
        fclose(fp);


    Kernel_initdata(&data6);
    Kernel_SchelduleEvery(FileVirtual,5,data6);
    Kern_RunSchel();
    Kern_Shutdown();
    }
    return 0;
}

#endif /*_Debug_of_Schelduller*/
